package com.chen.user.controller;

import com.chen.model.entity.user.UserAddress;
import com.chen.model.vo.common.Result;
import com.chen.model.vo.common.ResultCodeEnum;
import com.chen.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cgj
 * @date 4/26/25 8:59 AM
 */
@RequestMapping("/api/user/userAddress/auth")
@RestController
public class UserAddrController {

    @Autowired
    private UserAddressService userAddressService;


    /**
     * /api/user/userAddress/auth/getAddrById/{id}
     * 根据地址id, 返回用户地址对象
     */
    @GetMapping("/getAddrById/{id}")
    public UserAddress getAddrById(@PathVariable Long id){
        return userAddressService.getAddrById(id);
    }
    /**
     * /api/user/userAddress/auth/findUserAddressList
     *获取用户地址列表
     * @return
     */
    @GetMapping("/findUserAddressList")
    public Result<List<UserAddress>> findUserAddressList(){
        List<UserAddress> userAddressList=userAddressService.findUserAddressList();
        return Result.build(userAddressList, ResultCodeEnum.SUCCESS);
    }
}
